package com.cerosoft.components;

import java.util.List;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;

import com.cerosoft.utils.IndexChangeListener;

public class CustomedTitleBar extends TextView implements IndexChangeListener {

	private List<String> imgs = null;

	private int currIndex = -1;

	private void getViewByIndex() {
		if (imgs == null) {
			return;
		}
		setText(imgs.get(currIndex));
	}

	public void initTitleBar(List<String> imgs, int currIndex) {
		this.imgs = imgs;
		this.currIndex = currIndex;
		getViewByIndex();
	}

	public CustomedTitleBar(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	@Override
	public int indexAdd() {
		if (imgs != null && currIndex < imgs.size() - 1) {
			currIndex++;
			getViewByIndex();
		}
		return 0;
	}

	@Override
	public int indexSub() {
		if (imgs != null && currIndex > 0) {
			currIndex--;
			getViewByIndex();
		}
		return 0;
	}

}
